-
-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New text tool #4383
base: beta
Are you sure you want to change the base?
New text tool #4383
Conversation
757f937
to
3456fc2
Compare
6e06e9a
to
e7931fb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy made some suggestions
doc::BlendMode::SRC); | ||
} | ||
|
||
void renderExtraCelText(bool withSelection) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: parameter 'withSelection' is unused [misc-unused-parameters]
void renderExtraCelText(bool withSelection) { | |
void renderExtraCelText(bool /*withSelection*/) { |
|
||
void WritingTextState::onEditorResize(Editor* editor) | ||
{ | ||
gfx::PointF scale(editor->projection().scaleX(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: variable 'scale' of type 'gfx::PointF' (aka 'PointT') can be declared 'const' [misc-const-correctness]
gfx::PointF scale(editor->projection().scaleX(), | |
gfx::PointF const scale(editor->projection().scaleX(), |
|
||
void WritingTextState::onEditorResize(Editor* editor) | ||
{ | ||
gfx::PointF scale(editor->projection().scaleX(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: narrowing conversion from 'double' to 'float' [bugprone-narrowing-conversions]
gfx::PointF scale(editor->projection().scaleX(),
^
void WritingTextState::onEditorResize(Editor* editor) | ||
{ | ||
gfx::PointF scale(editor->projection().scaleX(), | ||
editor->projection().scaleY()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: narrowing conversion from 'double' to 'float' [bugprone-narrowing-conversions]
editor->projection().scaleY());
^
src/ui/entry.cpp
Outdated
@@ -235,6 +236,17 @@ gfx::Rect Entry::getEntryTextBounds() const | |||
return onGetEntryTextBounds(); | |||
} | |||
|
|||
gfx::Rect Entry::getCharBoxBounds(const int charBoxIndex) | |||
{ | |||
gfx::Rect bounds; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: variable 'bounds' of type 'gfx::Rect' (aka 'RectT') can be declared 'const' [misc-const-correctness]
gfx::Rect bounds; | |
gfx::Rect const bounds; |
src/ui/entry.cpp
Outdated
@@ -569,7 +581,8 @@ | |||
indexBox = j+1; | |||
} | |||
|
|||
int x = bounds().x + border().left() + segmentWidth + m_boxes[indexBox].width / 2; | |||
int x = bounds().x + border().left() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: variable 'x' of type 'int' can be declared 'const' [misc-const-correctness]
int x = bounds().x + border().left() | |
int const x = bounds().x + border().left() |
src/ui/entry.cpp
Outdated
@@ -569,7 +581,8 @@ | |||
indexBox = j+1; | |||
} | |||
|
|||
int x = bounds().x + border().left() + segmentWidth + m_boxes[indexBox].width / 2; | |||
int x = bounds().x + border().left() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: narrowing conversion from 'float' to 'int' [bugprone-narrowing-conversions]
int x = bounds().x + border().left()
^
src/ui/entry.cpp
Outdated
@@ -569,7 +581,8 @@ | |||
indexBox = j+1; | |||
} | |||
|
|||
int x = bounds().x + border().left() + segmentWidth + m_boxes[indexBox].width / 2; | |||
int x = bounds().x + border().left() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: narrowing conversion from 'int' to 'float' [bugprone-narrowing-conversions]
int x = bounds().x + border().left()
^
@@ -569,7 +581,8 @@ | |||
indexBox = j+1; | |||
} | |||
|
|||
int x = bounds().x + border().left() + segmentWidth + m_boxes[indexBox].width / 2; | |||
int x = bounds().x + border().left() | |||
+ (segmentWidth + m_boxes[indexBox].width / 2) * m_scale.x; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: narrowing conversion from 'int' to 'float' [bugprone-narrowing-conversions]
+ (segmentWidth + m_boxes[indexBox].width / 2) * m_scale.x;
^
@@ -569,7 +581,8 @@ | |||
indexBox = j+1; | |||
} | |||
|
|||
int x = bounds().x + border().left() + segmentWidth + m_boxes[indexBox].width / 2; | |||
int x = bounds().x + border().left() | |||
+ (segmentWidth + m_boxes[indexBox].width / 2) * m_scale.x; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: result of integer division used in a floating point context; possible loss of precision [bugprone-integer-division]
+ (segmentWidth + m_boxes[indexBox].width / 2) * m_scale.x;
^
2890ebf
to
5591a59
Compare
This new font selector list installed fonts with its proper name. It still needs some extra work to select font set styles (regular, bold, italic, etc.)
If we clicked bold/italic, and then chose another font family, we were using the cached typeface inside the FontInfo instead of an update typeface with the selected styles applied (bold/italic). Now we don't cache the typeface inside FontInfo to avoid this.
This fixes the required output image size to render text in different languages when the text doesn't support the full range of the specified chars/code points, and multiple fonts/text runs are used.
This is the first (not yet production-ready) version of the interactive Text tool. The text input is done with a transparent ui::Entry, and on each text modification an ExtraCel is rendered with this same ui::Entry's TextBlob to be displayed in the canvas with the active zoom level. The ui::Entry is being painted along the text in the canvas (just for testing), but this is something to be fixed. Probably it will not be the case in the future and a fully customized rendering (onPaint()) process will be required.
Now we don't render the default ui::Entry edges, but we paint just a border of the text bounds + the rendered text highlighting selected text on the canvas itself. With this change click mouse positions are translated with a scale factor that changes depending on the app::Editor zoom.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy made some suggestions
|
||
void WritingTextState::onEditorResize(Editor* editor) | ||
{ | ||
const gfx::PointF scale(editor->projection().scaleX(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: narrowing conversion from 'double' to 'float' [bugprone-narrowing-conversions]
const gfx::PointF scale(editor->projection().scaleX(),
^
void WritingTextState::onEditorResize(Editor* editor) | ||
{ | ||
const gfx::PointF scale(editor->projection().scaleX(), | ||
editor->projection().scaleY()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: narrowing conversion from 'double' to 'float' [bugprone-narrowing-conversions]
editor->projection().scaleY());
^
@@ -569,7 +580,8 @@ int Entry::getCaretFromMouse(MouseMessage* mousemsg) | |||
indexBox = j+1; | |||
} | |||
|
|||
int x = bounds().x + border().left() + segmentWidth + m_boxes[indexBox].width / 2; | |||
const int x = bounds().x + border().left() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: narrowing conversion from 'float' to 'int' [bugprone-narrowing-conversions]
const int x = bounds().x + border().left()
^
@@ -569,7 +580,8 @@ int Entry::getCaretFromMouse(MouseMessage* mousemsg) | |||
indexBox = j+1; | |||
} | |||
|
|||
int x = bounds().x + border().left() + segmentWidth + m_boxes[indexBox].width / 2; | |||
const int x = bounds().x + border().left() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: narrowing conversion from 'int' to 'float' [bugprone-narrowing-conversions]
const int x = bounds().x + border().left()
^
A work-in-progress to convert the "insert text" command into an interactive "text tool."